1.1 Introduction to MakeCode

MakeCode is an open-source programming tool launched by Microsoft for teenagers and programming beginners. It features a dual mode of graphical drag-and-drop and code editing, lowering the threshold for programming entry and adapting to multiple hardware scenarios to quickly realize ideas.

MakeCode official website: https://makecode.microbit.org/

1.2 Introduction to micro:bit

micro:bit is a microcomputer specifically designed for children's programming education and applying technological knowledge to solve problems. HUSKYLENS 2 is compatible with micro:bit, enabling the development of various interesting visual recognition projects through graphical programming.

Purchase link for micro:bit V2:click here

2. Hardware Connection & Preparation Materials

Preparation Materials

Insert the micro:bit into the compatible expansion board. Connect the expansion board to the computer using the USB-C cable. Insert the 4-Pin I2C/UART Sensor Cable into the I2C/UART interface of HUSKYLENS 2, and connect the other end to the "5V Huskylens" port on the expansion board. Since HUSKYLENS 2 has specific power requirements, use an additional USB-C cable to connect to the power port of HUSKYLENS 2, with the other end connected to a computer or compatible power supply.

Refer to the following image for the wiring diagram:

Interface Diagram

3. Load the HUSKYLENS 2 Library in MakeCode

Go to the MakeCode website and log in at https://makecode.microbit.org/, then click Import

Interface Diagram

Select Import URL

Interface Diagram

Enter https://github.com/DFRobot/pxt-DFRobot_HuskyLensV2 and click Go ahead!

Interface Diagram

Once imported successfully, the page will appear as follows.

Interface Diagram

The current latest system version is 1.1.6. Find System Settings > Device Information to check your current system version. We recommend updating to the latest version to experience new features. Update tutorial: Click here

Interface Diagram

4. Face Recognition Project Example

4.1 Recognize Faces and Output Related Data

When face recognition is enabled, faces appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected faces, total trained faces, center-closest face, nth detected face, and specified ID face. This data includes the face’s ID, name, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a face to observe the output.

As shown, when HuskyLens 2 detects two previously trained faces named "JACK" and "TOM", the following data will display:

How to learn faces, please refer to the [Face Recognition tutorial](https://wiki.dfrobot.com/_SKU_SEN0638_Gravity_HUSKYLENS_2_AI_Camera_Vision_Sensor#4.2 Face Recognition)

Operation Result: The serial port will output: total detected faces, ID of the center-closest face, name of the first detected face, and total the learned faces.

Interface Diagram

Interface Diagram

There are 2 detected faces, so the dot matrix display shows "2".

Interface Diagram

4.2 Obtaining Facial Feature Data

The system can capture facial feature and positional data for any detected face. Key readable information includes: face ID, name, width, height, center coordinates (X/Y), left/right eye coordinates (X/Y), left/right mouth corner coordinates (X/Y), and nose coordinates (X/Y).

For instance, the sample program below retrieves facial feature data of faces positioned near the camera’s center; this functionality works even for faces not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a face, and the serial port will display the face ID along with coordinates of its key facial features.

Interface Diagram

Interface Diagram

4.3 Obtaining Data of a Specific Face

When multiple faces with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth face in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two faces labeled ID 1. After activation, the serial port will output data statistics for these two faces.

Interface Diagram

Interface Diagram

4.4 Face Recognition Blocks Description

block Description
Used to obtain one set of Face Recognition data under the Face Recognition function of HUSKYLENS 2.
Determine if a human face is present in the current frame.
Retrieves data of the face closest to the screen cross cursor, including face ID, custom face name, center X/Y coordinates, width, height, left/right eye X/Y coordinates, left/right mouth corner X/Y coordinates, and nose X/Y coordinates.
Get the total number of faces detected on the screen, including both unregistered and registered faces.
When multiple faces are detected, retrieves data for a specified face.
Get the total number of learned faces , regardless of whether they appear in the current frame.
Determine if a face with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in the order they were learned.
Gets the total number of detected faces with a specified ID on the screen.
Obtain the number of faces with the specified ID in the current frame.
When multiple faces are detected, retrieve the relevant data of a specified face.

5.Object Recognition Project Example

5.1Recognize Objects and Output Related Data

When object recognition is enabled, objects appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected objects, total trained objects, center-closest object, nth detected object, and specified ID object. This data includes the object's ID, name, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with an object to observe the output.
As shown, when HuskyLens 2 detects two objects named "cell phone" and "cup", the following data will display:
How to learn objects, please refer to the Object Recognition tutorial

Operation Result: The serial port will output: total detected objects, ID of the center-closest object, name of the first detected object, and total the learned objects.

Interface Diagram

There are 2 detected objects, so the dot matrix display shows "2".

Interface Diagram

5.2 Obtaining Object Feature Data

The system can capture object feature and positional data for any detected object. Key readable information includes: object ID, name, width, height, and center coordinates (X/Y).
For instance, the sample program below retrieves object feature data of objects positioned near the camera's center; this functionality works even for objects not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with an object, and the serial port will display the object ID along with its positional data.

Interface Diagram

5.3 Obtaining Data of a Specific Object

When multiple objects with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth object in the detected sequence.
Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two objects labeled ID 1. After activation, the serial port will output data statistics for these two objects.

Interface Diagram

5.4 Object Recognition Blocks Description

block Description
Used to obtain one set of Object Recognition data under the Object Recognition function of HUSKYLENS 2.
Determine if an object is present in the current frame.
Retrieves data of the object closest to the screen cross cursor, including object ID, custom object name, center X/Y coordinates, width, and height.
Get the total number of objects detected on the screen, including both unregistered and registered objects.
When multiple objects are detected, retrieves data for a specified object.
Get the total number of learned objects, regardless of whether they appear in the current frame.
Determine if an object with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in the order they were learned.
Gets the total number of detected objects with a specified ID on the screen.
When multiple faces appear, obtain the relevant data of a specified face.
When multiple faces with the same ID appear, obtain the relevant data of a specified face.

6. Object Tracking Project Example

6.1 Track Objects and Output Related Data

When object tracking is enabled, objects appearing on the HuskyLens 2 screen will be detected, framed, and tracked, allowing you to access key data: tracked object ID, object name, center coordinates (XY), width,height,and confidence level will be displayed (confidence level cannot currently be retrieved via program. The system can continuously follow a learned object and provide real-time positional data.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HUSKYLENS 2 camera with the object to be tracked. You must first define the target object by drawing a bounding box.
As shown, when HuskyLens 2 successfully tracks a previously learned object named "cell phone", the following data will display:
How to set up object tracking, please refer to the Object Tracking tutorial

Operation Result: The serial port will output: tracked object ID, X coordinate, Y coordinate, width, and height.

Interface Diagram

6.2 Object Tracking Blocks Description

block Description
Used to obtain one set of Object Tracking data under the Object Tracking function of HUSKYLENS 2.
Determine if a trackable object is present in the current frame.
Retrieves data of the tracked object, including object ID, custom object name, center X/Y coordinates, width, and height.

7. Color Recognition Project Example

7.1 Recognize Colors and Output Related Data

When color recognition is enabled, color blocks appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected color blocks, total trained colors, center-closest color block, nth detected color block, and specified ID color. This data includes the color's ID, name, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a color block to observe the output.
As shown, when HuskyLens 2 detects three colors named "Yellow" and "Blue", the following data will display:
How to learn colors, please refer to the Color Recognition tutorial

Operation Result: The serial port will output: total detected color blocks, ID of the center-closest color, name of the first detected color, and total the learned colors.

Interface Diagram

There are 3 detected color blocks, so the dot matrix display shows "3".、

Interface Diagram

7.2 Obtaining Data of a Specific Color

When multiple color blocks with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth color block in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two color blocks labeled ID 1. After activation, the serial port will output data statistics for these two color blocks, including their individual positions and dimensions.

Interface Diagram

7.3 Color Recognition Blocks Description

block Description
Used to obtain one set of Color Recognition data under the Color Recognition function of HUSKYLENS 2.
Determine if a color block is present in the current frame.
Retrieves data of the color block closest to the screen cross cursor, including color ID, custom color name, center X/Y coordinates, width, and height.
Get the total number of color blocks detected on the screen, including both unregistered and registered colors.
When multiple color blocks are detected, retrieves data for a specified color block.
Get the total number of learned colors, regardless of whether they appear in the current frame.
Determine if a color with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in the order they were learned.
Gets the total number of detected color blocks with a specified ID on the screen.
When multiple colors appear, obtain the relevant data of a specified face.
When multiple colors with the same ID appear, obtain the relevant data of a specified color.

8. Object Classification Project Example

8.1 Object Classification and Output Related Data

When object classification is enabled, HuskyLens 2 can classify 1000 fixed categories of objects and identify learned objects, allowing you to access key data: total detected objects,classified object ID, object name). The system uses pre-trained models to recognize common objects without requiring extensive training.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Point the HuskyLens 2 camera at various objects to observe the classification results.
As shown, when HuskyLens 2 successfully classifies an object such as "mouse", the following data will display:

How to use object classification, please refer to the Object Classification tutorial

Operation Result: The serial port will output: classified object name.

Interface Diagram

8.2 Object Classification Blocks Description

block Description
Used to obtain one set of Object Classification data under the Object Classification function of HUSKYLENS 2.
Determine if a recognizable object is present and classified in the current frame.
Get the total number of object detected on the screen.
Retrieves data of the classified object, including object ID and object name based on the pre-trained classification model.

9. Self-Learning Object Classification Project Example

##9.1 Self-Learning Object Classification and Output Related Data

When self-learning classification is enabled, HuskyLens 2 can learn and recognize custom objects defined by the user, allowing you to access key data: total detected objects,learned object ID, object name, and confidence level will be displayed (confidence level cannot currently be retrieved via program). Unlike the fixed-category object classification, this function enables users to train the device to recognize specific, personalized objects.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. First, train HuskyLens 2 with your custom objects, then point the camera at the learned objects to observe the recognition results.
As shown, when HuskyLens 2 successfully recognizes a previously learned custom object such as "lenmon" the following data will display:
How to use self-learning classification, please refer to the Self-Learning Classification tutorial

Operation Result: The serial port will output: learned object ID, object name, and recognition status. . If no custom name is set, the default name "Object" will be displayed.

Interface Diagram

9.2 Self-Learning Object Classification Blocks Description

block Description
Used to obtain one set of Self-Learning Classification data under the Self-Learning Classification function of HUSKYLENS 2.
Determine if a previously learned object is present and recognized in the current frame.
Retrieves data of the recognized learned object, including object ID and custom object name. IDs start from 1 in learning order.

10. Hand Gesture Recognition Project Example

10.1 Hand Gesture Recognition and Output Related Data

When hand gesture recognition is enabled, hand gestures appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected gestures, total trained gestures, center-closest gesture, nth detected gesture, and specified ID gesture. This data includes the gesture's ID, name, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a hand gesture to observe the output.

As shown, when HuskyLens 2 detects one previously trained gestures named "gesture", the following data will display:

How to learn hand gestures, please refer to the Hand Gesture Recognition tutorial

Operation Result: The serial port will output: total detected gestures, ID of the center-closest gesture, name of the first detected gesture, and total the learned gestures.

Interface Diagram

There are 2 detected gestures, so the dot matrix display shows "2".

Interface Diagram

10.2 Obtaining Hand Gesture Recognition Feature Data

The system can capture hand gesture feature and positional data for any detected gesture. Key readable information includes: gesture ID, name, width, height, center coordinates (X/Y), wrist coordinates (X/Y), and coordinates for finger bases, joints, and fingertips.

For instance, the sample program below retrieves hand gesture feature data of gestures positioned near the camera's center; this functionality works even for gestures not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a hand gesture, and the serial port will display the gesture ID along with coordinates of its key hand features.

Interface Diagram

10.3 Obtaining Data of a Specific Hand Gesture

When multiple hand gestures with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth gesture in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two gestures labeled ID 1. After activation, the serial port will output data statistics for these two gestures, including their individual positions and dimensions.

Interface Diagram

10.4 Hand Gesture Recognition Blocks Description

block Description
Used to obtain one set of Hand Gesture Recognition data under the Hand Gesture Recognition function of HUSKYLENS 2.
Determine if a hand gesture is present in the current frame.
Retrieves data of the gesture closest to the screen cross cursor, including gesture ID, gesture name, center X/Y coordinates, width, height, and detailed keypoint coordinates including wrist position and finger keypoints.
Get the total number of gestures detected on the screen, including both unregistered and registered gestures.
When multiple gestures are detected, retrieves data for a specified gesture.
Get the total number of learned gestures, regardless of whether they appear in the current frame.
Determine if a gesture with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected gestures with a specified ID on the screen.
When multiple gesture are detected, retrieve the relevant data of a specified gesture.
When multiple gestures with the same ID are detected, retrieve the relevant data of a specified gesture.When multiple gestures with the same ID are detected, retrieve the relevant data of a specified gesture.

11. Pose Recognition Project Example

11.1 Pose Recognition and Output Related Data

When pose recognition is enabled, human poses appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected poses, total trained poses, center-closest pose, nth detected pose, and specified ID pose. This data includes the pose's ID, name, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a human pose to observe the output.

As shown, when HuskyLens 2 detects one previously trained poses named "pose" , the following data will display:

How to learn poses, please refer to the Pose Recognition tutorial

Operation Result: The serial port will output: total detected poses, ID of the center-closest pose, name of the first detected pose, and total the learned poses.

Interface Diagram

There are 2 detected poses, so the dot matrix display shows "2".

Interface Diagram

11.2 Obtaining Pose Recognition Feature Data

The system can capture pose feature and body keypoint data for any detected human pose. Key readable information includes: pose ID, name, width, height, center coordinates (X/Y), and coordinates for body joints including eye,ear,shoulders, elbows, wrists, hips, knees, and ankles.

For instance, the sample program below retrieves pose feature data of human poses positioned near the camera's center; this functionality works even for poses not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a human pose, and the serial port will display the pose ID along with coordinates of its key body joints.

Interface Diagram

11.3 Obtaining Data of a Specific Pose

When multiple human poses with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth pose in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two poses labeled ID 1. After activation, the serial port will output data statistics for these two poses, including their individual positions, dimensions, and body joint coordinates.

Interface Diagram

11.4 Pose Recognition Blocks Description

block Description
Used to obtain one set of Pose Recognition data under the Pose Recognition function of HUSKYLENS 2.
Determine if a human pose is present in the current frame.
Retrieves data of the pose closest to the screen cross cursor, including pose ID, pose name, center X/Y coordinates, width, height, anddetailed body keypoint coordinates including eye, ear, shoulders, elbows, wrists, hips, knees, and ankles.
Get the total number of poses detected on the screen, including both unregistered and registered poses.
When multiple poses are detected, retrieves data for a specified pose.
Get the total number of learned poses, regardless of whether they appear in the current frame.
Determine if a pose with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected poses with a specified ID on the screen.
When multiple poses are detected, retrieve the relevant data of a specified pose.
When multiple poses with the same ID are detected, retrieve the relevant data of a specified pose.

12.License Recognition Project Example

12.1 License Recognition and Output Related Data

When license recognition is enabled, license plates appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected license plates, total trained license plates, center-closest license plate, nth detected license plate, and specified ID license plate. This data includes the license plate's ID, name, license number, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a license plate to observe the output.
As shown, when HuskyLens 2 detects one previously trained license plates, the following data will display:
How to learn license plates, please refer to the License Recognition tutorial

Operation Result: The serial port will output: total detected license plates, ID of the center-closest and first license plate.

Interface Diagram

There are 2 detected license plates, so the dot matrix display shows "2".

Interface Diagram

12.2 Obtaining License Recognition Feature Data

The system can capture detailed license plate feature data for any detected license plate. Key readable information includes: license plate ID, name, license number, width, height, and center coordinates (X/Y).

For instance, the sample program below retrieves license plate feature data positioned near the camera's center; this functionality works even for license plates not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a license plate, and the serial port will display the license plate ID along with its recognized license number and positional data.

Interface Diagram

12.3 Obtaining Data of a Specific License

When multiple license plates with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth license plate in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two license plates labeled ID 1. After activation, the serial port will output data statistics for these two license plates, including their individual ID, license plate numbers, and coordinates.

Interface Diagram

12.4 License Recognition Blocks Description

block Description
Used to obtain one set of License Recognition data under the License Recognition function of HUSKYLENS 2.
Determine if a license plate is present in the current frame.
Retrieves data of the license plate closest to the screen cross cursor, including license ID, name, license number, center X/Y coordinates, width, and height.
Get the total number of license plates detected on the screen, including both unregistered and registered license plates.
When multiple license plates are detected, retrieves data for a specified license plate.
Get the total number of learned license plates, regardless of whether they appear in the current frame.
Determine if a license plate with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected license plates with a specified ID on the screen.
When multiple license plates are detected, retrieve the relevant data of a specified license plate.
When multiple license plates with the same ID are detected, retrieve the relevant data of a specified license plate.

13. Optical Char Recognition Project Example

13.1 Optical Char Recognition and Output Relevant Data

When optical character recognition is enabled, text blocks appearing on the HuskyLens 2 screen will be detected and framed, allowing you to access key data: total detected text blocks, recognized text content, center-closest text block, and specified ID text block. This data includes the text block's ID, name, text content, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with text content to observe the output.
As shown, when HuskyLens 2 detects text blocks such as "happy", the following data will display:
How to use optical character recognition, please refer to the Optical Char Recognition tutorial
Operation Result: The serial port will output: ID,content, coordinates and size of the center-closest text block.

Interface Diagram

13.2 Optical Char Recognition Blocks Description

block Description
Used to obtain one set of Optical Char Recognition data under the Optical Char Recognition function of HUSKYLENS 2.
DDetermine if a text block is present in the current frame.
Retrieves data of the text block closest to the screen cross cursor, including text ID, name, recognized text content, center X/Y coordinates, width, and height.
Get the total number of text blocks detected on the screen.
Determine if a text block with the specified ID exists in the frame.
Get the total number of learned license plates, regardless of whether they appear in the current frame.
Determine if a license plate with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected license plates with a specified ID on the screen.
When multiple license plates are detected, retrieve the relevant data of a specified license plate.
When multiple license plates with the same ID are detected, retrieve the relevant data of a specified license plate.

14. Line Tracking Project Example

14.1 Line Tracking and Output Relevant Data

When line tracking is enabled, HuskyLens 2 can detect and track lines in its field of view, allowing you to access key data: line length, angle, X/Y components, intersection branch count, and specific branch data.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Point the HuskyLens 2 camera at a line or track to observe the output.
As shown, when HuskyLens 2 detects lines and intersections, the following data will display:
How to use line tracking, please refer to the Line Tracking tutorial

Operation Result: The serial port will output: current line length, angle, X/Y components, intersection branch count.

Interface Diagram

14.2 Line Tracking Blocks Description

block Description
Used to obtain one set of Line Tracking data under the Line Tracking function of HUSKYLENS 2.
Determine if a line is present in the current frame.
Retrieves data of the detected line including vector components, orientation angle, and line length.
Obtain the number of branches at detected intersections.
When multiple branches are detected, retrieves data for a specified branch starting counterclockwise.

15. Face Emotion Recognition Project Example

15.1 Face Emotion Recognition and Output Relevant Data

When face emotion recognition is enabled, facial expressions appearing on the HuskyLens 2 screen will be detected and analyzed, allowing you to access key data: total detected emotions, emotion types, center-closest emotion, and specified ID emotion. This data includes the emotion's ID, name, center coordinates (XY), width, and height.Under the Face Emotion Recognition function, HUSKYLENS 2 can recognize 7 specific emotions: angry (ID 1), disgust (ID 2), fear (ID 3), happy (ID 4), neutral (ID 5), sad (ID 6), and surprise (ID 7). These emotions have already been learned by HUSKYLENS 2 at the factory, so users do not need to learn them manually again.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a face showing emotion to observe the output.
As shown, when HuskyLens 4 detects facial emotions such as "Happiness" "Neural"and“Fear”, the following data will display:
How to use face emotion recognition, please refer to the Face Emotion Recognition tutorial

Operation Result: The serial port will output: total detected emotions, ID of the center-closest emotion, and emotion recognition results.

Interface Diagram

There are 4 detected emotions, so the dot matrix display shows "4".

Interface Diagram

15.2 Obtaining Face Emotion Recognition Feature Data

The system can capture detailed emotion analysis data for any detected facial expression. Key readable information includes: emotion ID, name, width, height, center coordinates (X/Y), and confidence levels for different emotion categories.

For instance, the sample program below retrieves emotion feature data of facial expressions positioned near the camera's center; this functionality works with the 7 pre-trained emotion categories.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a face showing emotion, and the serial port will display the emotion ID along with detailed recognition data.

Interface Diagram

15.3 Obtaining Data of a Specific Face Emotion

When multiple facial emotions with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth emotion in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two emotions labeled ID 4 (HAPPY). After activation, the serial port will output data statistics for these emotions, including their individual positions.

Interface Diagram

15.4 Face Emotion Recognition Blocks Description

block Description
Used to obtain one set of Face Emotion Recognition data under the Face Emotion Recognition function of HUSKYLENS 2.
Determine if a facial emotion is present in the current frame.
Retrieves data of the emotion closest to the screen cross cursor, including emotion ID, emotion name, center X/Y coordinates, width, and height.
Get the total number of emotions detected on the screen.
When multiple emotions are detected, retrieves data for a specified emotion.
Gets the total number of learned emotions on the screen.
Obtain the number of emotions with the specified ID in the current frame.
When multiple face emotions are detected, retrieve the relevant data of a specified emotion.
When multiple face enotions with the same ID are detected, retrieve the relevant data of a face emotion.

16. Tag Recognition Project Example

16.1 Tag Recognition and Output Relevant Data

When tag recognition is enabled, AprilTag tags appearing on the HuskyLens 2 screen will be detected and decoded, allowing you to access key data: total detected tags, total trained tags, center-closest tag, nth detected tag, and specified ID tag. This data includes the tag's ID,name, content, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with an AprilTag to observe the output.

As shown, when HuskyLens 2 detects two tags such as "6" and "2", the following data will display:

How to learn tags, please refer to the Tag Recognition tutorial

Operation Result: The serial port will output: total detected tags, ID of the center-closest tag, ID of the first detected tag.

Interface Diagram

There are 2 detected tags, so the dot matrix display shows "2".

Interface Diagram

16.2 Obtaining Tag Recognition Feature Data

The system can capture detailed tag recognition data for any detected AprilTag. Key readable information includes: tag ID, name,content, width, height, center coordinates (X/Y).

For instance, the sample program below retrieves tag feature data positioned near the camera's center; this functionality works even for tags not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with an AprilTag, and the serial port will display the tag ID along with its decoded content, positional and dimension.

Interface Diagram

16.3 Obtaining Data of a Specific Tag

When multiple tags with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth tag in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two tags labeled ID0. After activation, the serial port will output data statistics for these two tags, including their individual positions, dimensions, and decoded content.

Interface Diagram

16.4 Tag Recognition Blocks Description

block Description
Used to obtain one set of Tag Recognition data under the Tag Recognition function of HUSKYLENS 2.
Determine if a tag is present in the current frame.
Retrieves data of the tag closest to the screen cross cursor, including tag ID, decoded content, center X/Y coordinates, width, and height.
Get the total number of tags detected on the screen, including both unregistered and registered tags.
When multiple tags are detected, retrieves data for a specified tag.
Get the total number of learned tags, regardless of whether they appear in the current frame.
Determine if a tag with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected tags with a specified ID on the screen.
When multiple tags are detected, retrieve the relevant data of a specified tag.
When multiple tags are detected with the same ID, retrieve the relevant data of a specified tag.

17. QR Code Recognition Project Example

17.1 QR Recognition and Output Relevant Data

When QR code recognition is enabled, QR codes appearing on the HuskyLens 2 screen will be detected and decoded, allowing you to access key data: total detected QR codes, total trained QR codes, center-closest QR code, nth detected QR code, and specified ID QR code. This data includes the QR code's ID, name,content, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a QR code to observe the output.
As shown, when HuskyLens 2 detects two QR codes such as "abc" and "hello", the following data will display:

How to learn QR codes, please refer to the QR Code Recognition tutorial

Operation Result: The serial port will output: total detected QR codes, ID of the center-closest QR code, and IDt of the first detected QR code.

Interface Diagram

There are 2 detected QR codes, so the dot matrix display shows "2".

Interface Diagram

17.2 Obtaining QR Recognition Feature Data

The system can capture detailed QR code recognition data for any detected QR code. Key readable information includes: QR code ID, name,content, width, height, center coordinates (X/Y), and decoding confidence levels.

For instance, the sample program below retrieves QR code feature data positioned near the camera's center; this functionality works even for QR codes not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a QR code, and the serial port will display the QR code ID along with its decoded content, positional and dimensions.

Interface Diagram

17.3 Obtaining Data of a Specific QR Code

When multiple QR codes with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth QR code in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two QR codes labeled ID 0. After activation, the serial port will output data statistics for these two QR codes, including their individual positions, dimensions, and decoded content.

Interface Diagram

17.4 QR Code Blocks Description

block Description
Used to obtain one set of QR Code Recognition data under the QR Code Recognition function of HUSKYLENS 2.
Determine if a QR code is present in the current frame.
Retrieves data of the QR code closest to the screen cross cursor, including QR ID, decoded content, center X/Y coordinates, width, and height.
Get the total number of QR codes detected on the screen, including both unregistered and registered QR codes.
When multiple QR codes are detected, retrieves data for a specified QR code.
Get the total number of learned QR codes, regardless of whether they appear in the current frame.
Determine if a QR code with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected QR codes with a specified ID on the screen.
When multiple QR codes are detected, retrieve the relevant data of a specified QR code.
When multiple QR codes with the same ID are detected, retrieve the relevant data of a specified QR code.

18. Barcode Recognition Project Example

18.1 Barcode Recognition and Output Relevant Data

When barcode recognition is enabled, barcodes appearing on the HuskyLens 2 screen will be detected and decoded, allowing you to access key data: total detected barcodes, total trained barcodes, center-closest barcode, nth detected barcode, and specified ID barcode. This data includes the barcode's ID, content, center coordinates (XY), width, and height.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with a barcode to observe the output.

As shown, when HuskyLens 2 detects three barcodes such as "1434" ,“hello”and "23", the following data will display:

How to learn barcodes, please refer to the Barcode Recognition tutorial

Operation Result: The serial port will output: total detected barcodes, ID of the center-closest barcode, content of the first detected barcode, and total the learned barcodes.

Interface Diagram

There are 3 detected barcodes, so the dot matrix display shows "3".

Interface Diagram

18.2 Obtaining Barcode Recognition Feature Data

The system can capture detailed barcode recognition data for any detected barcode. Key readable information includes: barcode ID, content, width, height, center coordinates (X/Y), and decoding confidence levels.

For instance, the sample program below retrieves barcode feature data positioned near the camera's center; this functionality works even for barcodes not previously learned.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with a barcode, and the serial port will display the barcode ID along with its decoded content, positional and dimensions.

Interface Diagram

18.3 Obtaining Data of a Specific Barcode

When multiple barcodes with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth barcode in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two barcodes labeled ID 1. After activation, the serial port will output data statistics for these two barcodes, including their individual positions, dimensions, and decoded content.

Interface Diagram

18.4 Barcode Recognition Blocks Description

block Description
Used to obtain one set of Barcode Recognition data under the Barcode Recognition function of HUSKYLENS 2.
Determine if a barcode is present in the current frame.
Retrieves data of the barcode closest to the screen cross cursor, including barcode ID, decoded content, center X/Y coordinates, width, and height.
Get the total number of barcodes detected on the screen, including both unregistered and registered barcodes.
When multiple barcodes are detected, retrieves data for a specified barcode.
Get the total number of learned barcodes, regardless of whether they appear in the current frame.
Determine if a barcode with the specified ID exists in the frame. Unlearned IDs are uniformly set to 0, and learned IDs are sorted in learning order.
Gets the total number of detected barcodes with a specified ID on the screen.
When multiple barcodes are detected, retrieve the relevant data of a specified barcode.
When multiple barcodes with the same ID are detected, retrieve the relevant data of a specified barcode.

19. Instance Segmentation Project Example

19.1 Instance Segmentation and Output Relevant Data

When instance segmentation is enabled, objects appearing on the HuskyLens 2 screen will be detected and their outlines marked, allowing you to access key data: total detected instances, instance categories, center-closest instance, and specified ID instance. This data includes the instance's ID, name, center coordinates (XY), width, height, and confidence level will be displayed (confidence level cannot currently be retrieved via program.

Example program:

Interface Diagram

Connect to micro:bit and click Download to transfer the program. After successful download, click Show Data to activate data output mode. Align the HuskyLens 2 camera with objects to observe the output.
As shown, when HuskyLens 2 detects instances such as "dog" and "person", the following data will display:

How to use instance segmentation, please refer to the Instance Segmentation tutorial

Operation Result: The serial port will output: total detected instances, ID of the center-closest instance, ID of the first detected instance.

Interface Diagram

There are 2 detected instances, so the dot matrix display shows "2".

Interface Diagram

19.2 Obtaining Instance Segmentation Feature Data

The system can capture detailed instance segmentation data for any detected object. Key readable information includes: instance ID, category name, width, height, center coordinates (X/Y), and segmentation confidence levels(Confidence leverls cannot be displayed in serial output).

For instance, the sample program below retrieves instance feature data positioned near the camera's center.

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program to micro:bit. After successful download, click "Show Device" to activate data output. Align HuskyLens 2 with objects, and the serial port will display the instance ID along with detailed segmentation data.

Interface Diagram

19.3 Obtaining Data of a Specific Instance

When multiple instances with the same ID appear simultaneously, the program can count their occurrences and retrieve data for the nth instance in the detected sequence.

Example program:

Interface Diagram

Operation Result: As shown, click "Download" to transfer the program. Align HuskyLens 2 with two instances labeled ID 1. After activation, the serial port will output data statistics for these instances, including their individual positions and segmentation information.

Interface Diagram

19.4 Instance Segmentation Blocks Description

block Description
Used to obtain one set of Instance Segmentation data under the Instance Segmentation function of HUSKYLENS 2.
Determine if an instance is present in the current frame.
Retrieves data of the instance closest to the screen cross cursor, including instance ID, category name, center X/Y coordinates, width, and height.
Get the total number of instances detected on the screen.
When multiple instances are detected, retrieves data for a specified instance.
Determine if an instance with the specified ID exists in the frame.
Gets the total number of detected instances with a specified ID on the screen.
Obtain the number of instances with the specified ID in the current frame.
When multiple instances are detected, retrieve the relevant data of a specified instance.
When multiple instances with the same ID are detected, retrieve the relevant data of a specified instance.